package com.iris.live.services.data.repositories;

import com.iris.live.services.data.models.Itask基础设置Model;
import com.iris.live.services.data.models.Itask基础设置ModelPK;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by sxy on 2016/7/11
 */
@Transactional
public interface Itask基础设置Repository extends JpaRepository<Itask基础设置Model, Itask基础设置ModelPK>, JpaSpecificationExecutor<Itask基础设置Model> {
    /**
     * 删除所有权限数据
     *
     * @param permit 固定值"GROUP"
     * @return 删除数据的行数
     */
    @Modifying
    @Query("delete from Itask基础设置Model where 许可 = ?1 and 设置项目 like 'step%'")
    Integer deleteContractItemByPermit(String permit);

    @Query("SELECT a FROM Itask基础设置Model a where a.许可=?1 and a.设置项目 =?2")
    Itask基础设置Model finByPermitAndName(String permit, String name);

    @Query("update Itask基础设置Model a set a.值=?3,a.更新时间=?4,a.更新账号=?5 where a.许可=?1 and a.设置项目 =?2")
    @Modifying
    Integer updByPermitAndName(String permit, String name, String value, java.sql.Timestamp updTime,String updUser);
}